function createBitmapByName(name: string): egret.Bitmap {
    let result = new egret.Bitmap();
    let texture: egret.Texture = RES.getRes(name);
    result.texture = texture;
    return result;
}

function scaleHeight(aw: number, ah: number, bw: number) {
    return bw * ah / aw;
}

interface SceneImageOptions {
    x?: number;
    y?: number;
    width?: number;
    height?: number;
    mode: string;
    stageWidth?: number;
    stageHeight?: number;
}

function loadImgToScene(scene: eui.Component, resName: string, options: SceneImageOptions) {
    const img = createBitmapByName(resName);
    if (options.mode === 'fitW_alignLB') {
        const imgHt = scaleHeight(img['$bitmapWidth'], img['$bitmapHeight'], options.stageWidth);
        img.width = options.stageWidth;
        img.height = imgHt;
        img.x = 0;
        img.y = options.stageHeight - imgHt;
    } else if (options.mode === 'fitW_alignLT') {
        img.width = options.stageWidth;
        img.x = 0;
        img.y = 0;
    }
    scene.addChild(img);
}
